package cn.com.fssg.platform.base.handler.impl;

import cn.com.fssg.common.vo.DoubleVO;
import cn.com.fssg.platform.base.handler.InterfaceHandler;
import cn.com.fssg.platform.biz.BizUtil;
import cn.com.fssg.platform.biz.ExtendUtil;
import cn.com.fssg.platform.modules.engine.util.MinioUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author : xzt
 * @description :
 * @createDate : 2025/9/3 14:37
 */
public class WorkflowAttachmentDemo implements InterfaceHandler {

    private ExtendUtil extendUtil = ExtendUtil.cur();
    @Override
    public Object run(HttpServletRequest request, JSONObject jsonObject) throws Exception {
        MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
        Iterator<String> iter = multiRequest.getFileNames();
        ArrayList<File> fileList = new ArrayList<>();
        while (iter.hasNext()) {
            MultipartFile multipartFile = multiRequest.getFile(iter.next());
            // 创建临时文件
            File tempFile = File.createTempFile("", multipartFile.getOriginalFilename());
            // 将 MultipartFile 内容写入临时文件
            multipartFile.transferTo(tempFile);
            fileList.add(tempFile);
        }
        extendUtil.workflowAttachmentUpload(fileList,"751093933827547136","751093932489564160","","1756883312171","751093932510535681");
        return null;
    }
}

